{extends file="../global.html"}
{block name=body}

 

<form class="layui-form" action="" method="post" enctype="multipart/form-data">


 <div class="layui-form-item">
     <div class="layui-input-block">
    <p style="color:red;font-size:30px"></p>
    </div>
    
  </div>
   

  <div class="layui-form-item">
    <label class="layui-form-label">门店所在城市</label>
    <div class="layui-input-block">
      <input type="text" name="store_name"  placeholder="门店所在城市" autocomplete="off" class="layui-input store_name1">
    </div>
  </div>

    <div class="layui-form-item">
    <label class="layui-form-label">门店所属公司</label>
    <div class="layui-input-block">
      <input type="text" name="store_company"  placeholder="门店所属公司" autocomplete="off" class="layui-input store_name2">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">门店详细地址</label>
    <div class="layui-input-block">
      <input type="text" name="store_name"  placeholder="门店详细地址" autocomplete="off" class="layui-input store_name3">
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">门店联系电话</label>
    <div class="layui-input-block">
      <input type="text" name="store_phone"  placeholder="门店联系电话" autocomplete="off" class="layui-input store_name4">
    </div>
  </div>
  <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="return false">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
</form>
 
<script>
	
	/**
	 * http封装
	 */
	var httpCurl = function( url, params, callback){
		$.ajax({
			type: "POST",
			data:params,
			url: url,
      async: false,
			success: function( response ){
				if( typeof callback == 'function' )
					callback(response);
			}
		});	
	}
	
	var uid =0;
  

     $('.layui-btn').on('click',function(){
      // alert(uid);
        // $('.store_name1').bind('input propertychange',function(){
    var store_name = $('.store_name1').val();
      var store_name2 = $('.store_name2').val();
      var store_name3 = $('.store_name3').val();
      var store_name4 = $('.store_name4').val();
        if(store_name == ''){
        alert('请输入门店所属城市');
        return;
    }
      if(store_name2 == ''){
        alert('请输入门店所属公司');
        return;
      }
       if(store_name3 == ''){
        alert('请输入门店地址');
        return;
      }
       if(store_name4 == ''){
        alert('请输入门店电话');
        return;
      }
    httpCurl("{url('run/store/ajaxAdd')}", { store_name:store_name}, function(response){
       // alert(response);
      uid = response;
     
        });
         
      // });
     
		if(uid == 0){
			alert('请选择城市');
			return;
		}
    // alert(store_name2);
		httpCurl("{url('run/store/ajaxInsert')}", { store_name:store_name3,store_company:store_name2,store_phone:store_name4,uid:uid}, function(msgs){
			if(msgs == false)return false;
            window.location.href="index"; 
	
		});
                       
     });
                
</script>



{/block}
